package com.mby.controller;

import com.qiniu.util.Auth;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by developer_01 on 2018/6/22.
 */
@RestController
public class QiNiuController extends BaseController{

    private static String accessKey = "INl4R5plQtkAAoK8ZHskGA0LpJl0tgjH4kwu4rPI";
    private static String secretKey = "QU5j_cE0cF0bO5nGipEltdCk8js4HKgmOF48FlP9";

    /**
     * 获取七牛上传文件token
     * get /qiniu/token?bucket=live&key=213
     * @throws Exception
     */
    @GetMapping(value = "/qiniu/token")
    public void initWelcomeWords(String bucket,String key) throws Exception{
        Auth auth = Auth.create(accessKey, secretKey);
        String token = auth.uploadToken(bucket, key);
        respData(token);
    }

}
